import Vue from "vue";
import VueRouter from 'vue-router';
import Layout from '@/views/layout/indexLayout.vue'
import Login from '@/views/login/indexLogin.vue'
import Home from '@/views/home/homeContent.vue'

const Product=()=>import('@/views/product/productContent.vue')
const List=()=>import('@/views/product/list/productList.vue')
const Category=()=>import('@/views/product/category/productCategory.vue')
const ProductPage=()=>import('@/views/product/list/productPage.vue')

const User=()=>import('@/views/user/userContent.vue')
const UserList=()=>import('@/views/user/list/userList.vue')
const UserPage=()=>import('@/views/user/list/userPage.vue')

const Order=()=>import('@/views/order/orderContent.vue')
const OrderList=()=>import('@/views/order/list/orderList.vue')

const Admin=()=>import('@/views/admin/adminContent.vue')
const AdminList=()=>import('@/views/admin/list/adminList.vue')
const AdminPage=()=>import('@/views/admin/list/adminPage.vue')

Vue.use(VueRouter);

const routes=[
    {
        path:'/',
        component:Layout,
        meta:{
            title:'首页'
        },
        children:[
            {
                path:'/',
                name:'home',
                component:Home,
                meta:{
                    title:'首页'
                },
            },
            {
                path:'/product',
                name:'product',
                redirect:'/product/list',
                component:Product,
                meta:{
                    title:'产品管理'
                },
                children:[
                    {
                        path:'list', //访问路径：/product/list
                        name:'list',
                        component:List,
                        meta:{
                            title:'产品列表'
                        },
                    },
                    {
                        path:'category', //访问路径：/product/category
                        name:'categoty',
                        component:Category,
                        meta:{
                            title:'产品分类'
                        },
                    },
                    {
                        path:'productPage',
                        name:'productPage',
                        component:ProductPage,
                        meta:{//配置高亮标识
                            activeMenu:'/product/list',
                            title:'商品详情'
                        }
                    }
                ]
            },
            {
                path:'/user',
                name:'user',
                component:User,
                meta:{
                    title:'用户管理'
                },
                children:[
                    {
                        path:'list', //访问路径：/user/list
                        name:'userList',
                        component:UserList,
                        meta:{
                            title:'用户列表'
                        },
                    },
                    {
                        path:'userPage',
                        name:'userPage',
                        component:UserPage,
                        meta:{//配置高亮标识
                            activeMenu:'/user/list',
                            title:'用户详情'
                        }
                    }
                ]
            },
            {
                path:'/order',
                name:'order',
                component:Order,
                meta:{
                    title:'订单管理'
                },
                children:[
                    {
                        path:'list', //访问路径：/user/list
                        name:'orderList',
                        component:OrderList,
                        meta:{
                            title:'订单列表'
                        },
                    }
                ]
            },
            {
                path:'/admin',
                name:'admin',
                component:Admin,
                meta:{
                    title:'管理员管理'
                },
                children:[
                    {
                        path:'list',
                        name:'adminList',
                        component:AdminList,
                        meta:{
                            title:'管理员列表'
                        }
                    },
                    {
                        path:'adminPage',
                        name:'adminPage',
                        component:AdminPage,
                        meta:{//配置高亮标识
                            activeMenu:'/admin/list',
                            title:'管理员详情'
                        }
                    }
                ]
            }
        ]
    },{
        path:'/login',
        name:'login',
        component:Login
    }
]

const router = new VueRouter({
    mode: 'history',
    base:process.env.BASE_URL,
    routes
});

export default router
